import "./detailsuser.css"
import { getDetailsUser, getUserClass } from "../../api/home"
import { Link, useParams, useNavigate, useLocation } from "react-router-dom"
import React from "react";
function Detailsuser() {
    let navigate = useNavigate();//链接跳转
    let params = useParams(); //获取链接数据

    let [user, SetUser] = React.useState(null)
    let [uservideo, SetVideo] = React.useState(null)
    React.useEffect(() => {
        getDetailsUser(params.id).then(data => {
            // console.log(data.data);
            SetUser(data.data)
        })
        getUserClass(params.id).then(data => {
            console.log(data.data);
            SetVideo(data.data.list)
        })
    }, [])
    return user ? (
        <div className="detailsuser">
            <div className="header">

                <div className="header-wrap">
                    <i onClick={() => navigate(-1)} className="iconfont icon-zuobian"></i>
                    <div className="title">
                        {user.album_name}
                    </div>

                </div>

            </div>

            <div className="user">
                <div className="bg" style={{ background: `url("${user.album_img}") center center / 100%` }}>
                    <div className="bgs"></div>
                    <div className="info">
                        <div className="img">
                            <img src={user.album_logo} />
                        </div>
                        <div className="content">
                            <p className="title">{user.album_name}</p>
                            <p className="txt">{user.album_desc}</p>
                        </div>
                    </div>
                </div>
            </div>

            {/* 课程 */}
            <div className="course">
                <div className="title">
                    <div className="line"></div>
                    <h5>系列课程</h5>
                </div>
                <div className="content">
                    <ul>
                        {
                            uservideo && uservideo.map(item => {
                                return (
                                    <Link to={'/detailscourse/' + item.series_id} key={item.series_id}>
                                        <li>
                                            <div className='img'>
                                                <img src={item.series_image} />
                                                <span className='icons'>专辑</span>
                                                <i className='icon'></i>
                                                <span className='video-count'>{item.course_num}个视频</span>
                                            </div>
                                            <div className='text'>
                                                <h2>{item.series_name}</h2>
                                                <span>{item.series_title}</span>
                                            </div>
                                        </li>
                                    </Link>
                                )
                            })
                        }

                    </ul>
                </div>
            </div>
        </div>
    ) : null
}

export default Detailsuser; 